package demo4;

import java.util.HashSet;

public class Test {
    public int singleNumber(int[] nums) {
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i <nums.length ; i++) {
            if(!set.contains(nums[i])){
                set.add(nums[i]);
            }else {
                set.remove(nums[i]);
            }
        }
        for (int i = 0; i <
                nums.length; i++) {
            if(set.contains(nums[i])){
                System.out.println(nums[i]);
            }
        }
       return -1;
    }
    public static void main(String[] args) {
        int nums[] = {1,2,2,3,3,4,4,8};
        Test s =new Test();
        s.singleNumber(nums);
    }
}
